<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php


//<img src="../Images/Computer Pictures/Acer.large.jpg" width="220" height="139" alt="Acer" />

$connect = mysql_connect ("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("store",$connect) or die ("could not select DB!");


?>



<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../../CSS/Divlayouts.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Checkout</title>
<?php 

session_start();
if(@$_SESSION['status'] == " ")
{
$_SESSION['status']=NULL;
}
?>

<style type="text/css">
#Pannel {
	position:absolute;
	width:989px;
	height:700px;
	z-index:3;
	left: 263px;
	top: 250px;
}
#apDiv1 {
	position:absolute;
	width:166px;
	height:303px;
	z-index:4;
	left: 278px;
	top: 260px;
}
#apDiv2 {
	position:absolute;
	width:170px;
	height:302px;
	z-index:5;
	left: 469px;
	top: 261px;
}
#apDiv3 {
	position:absolute;
	width:179px;
	height:302px;
	z-index:6;
	left: 665px;
	top: 262px;
}
#apDiv4 {
	position:absolute;
	width:185px;
	height:302px;
	z-index:7;
	left: 864px;
	top: 261px;
}
#apDiv5 {
	position:absolute;
	width:167px;
	height:301px;
	z-index:8;
	left: 1075px;
	top: 263px;
}
#apDiv6 {
	position:absolute;
	width:168px;
	height:327px;
	z-index:9;
	left: 273px;
	top: 593px;
}
#apDiv7 {
	position:absolute;
	width:169px;
	height:330px;
	z-index:10;
	left: 470px;
	top: 592px;
}
#apDiv8 {
	position:absolute;
	width:175px;
	height:333px;
	z-index:11;
	left: 669px;
	top: 590px;
}
#apDiv9 {
	position:absolute;
	width:183px;
	height:330px;
	z-index:12;
	left: 866px;
	top: 591px;
}
#apDiv10 {
	position:absolute;
	width:164px;
	height:335px;
	z-index:13;
	left: 1075px;
	top: 589px;
}
#cart {
	position:absolute;
	width:108px;
	height:28px;
	z-index:6;
	left: 822px;
	top: -149px;
}
#apDiv11 {
	position:absolute;
	width:95px;
	height:37px;
	z-index:14;
	left: 33px;
	top: 232px;
}
#apDiv12 {
	position:absolute;
	width:95px;
	height:37px;
	z-index:15;
	left: 41px;
	top: 231px;
}
#apDiv13 {
	position:absolute;
	width:112px;
	height:38px;
	z-index:16;
	left: 41px;
	top: 231px;
}
#apDiv14 {
	position:absolute;
	width:97px;
	height:40px;
	z-index:17;
	left: 48px;
	top: 231px;
}
#apDiv15 {
	position:absolute;
	width:114px;
	height:42px;
	z-index:18;
	left: 28px;
	top: 230px;
}
#apDiv16 {
	position:absolute;
	width:112px;
	height:38px;
	z-index:19;
	left: 31px;
	top: 276px;
}
#apDiv17 {
	position:absolute;
	width:96px;
	height:39px;
	z-index:20;
	left: 505px;
	top: 819px;
}
#apDiv18 {
	position:absolute;
	width:116px;
	height:41px;
	z-index:21;
	left: 32px;
	top: 279px;
}
#apDiv19 {
	position:absolute;
	width:111px;
	height:42px;
	z-index:22;
	left: 40px;
	top: 277px;
}
#apDiv20 {
	position:absolute;
	width:99px;
	height:43px;
	z-index:23;
	left: 1113px;
	top: 814px;
}
#apDiv21 {
	position:absolute;
	width:112px;
	height:43px;
	z-index:24;
	left: 29px;
	top: 280px;
}
#apDiv22 {
	position:absolute;
	width:993px;
	height:163px;
	z-index:14;
	left: 264px;
	top: 962px;
}
</style>
</head>


<body>

<pre><p>                          <a href="index.php"><img src="../Resources/eMart logo.png" width="170" height="67" alt="Logo" /></a>                                                                <b><a  style="color:#000; text-decoration:none;" href="customer_support.php">Customer Support</a>  |  <a style="color:#000; text-decoration:none;" href="Policy.php">Privacy Policy</a></b>
                                              <?php if ((@$_SESSION['status']== NULL)||(@$_SESSION['status']== "OUT")){echo"Welcome! <a href='login.php'>Sign in</a> or <a href='Register.php'>Register</a>";} else { echo "Welcome ".($_SESSION['fname'])." ".($_SESSION['lname']) ."<pre>                                  <a  class='underline' href='index.php'>Logout</a>    <a class='underline' href='editaccount.php' >My Account</a> </pre>" ; } ?> 
<div id="DivHR"><hr/></div>
<div  style="background-image:url(../../Resources/Search%20Bar.png)" id="DivBar"></div>
<div id="Pannel" style="background-image:url(../../Resources/Gallery%20Pannel.png); background-repeat:no-repeat">

<div id="cart"><a href="../cart.php"><img src="../../Resources/Mycart.png" width="100" height="25" alt="cart" /></a></div>



</div>


<div id="DivSearchBar">
<form name="emartsearch" action="emartsearchresult.php" method="post">
    <select name="criteria">
        <option value="1">All Criterias</option>
        <option value="2">Product Name</option>
        <option value="3">Product Code</option>
        <option value="4">Category</option> 

    </select>
    <input type="text" style="width: 400px" value="Enter search term" size="25" maxlength="20" name="parameter" />
        <input type="submit" name="search" value="Search" />
</form></div>


<div id="apDiv1">
<?php

echo $_SESSION['id'];


$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
mysql_select_db ("web project",$con) or die ("could not select DB!");

$sql = "SELECT cart.Member_Id, products.ImageSmall, products.ProductName, cart.Product_Code, cart.Product_Quantity, cart.Product_Cost 
		FROM cart
		INNER JOIN products
		ON products.ProductCode = cart.Product_Code";

$result = mysql_query($sql);

		
		echo "E- mart Shopping Cart";
		echo "<br>";
		echo "<br>";
		
		print "<table border=2>";
		print "<tr>";
		print "<td>Member ID</td>";
		print "<td>Product Image</td>";
		echo "<td>Product Name</td>";
		echo "<td>Product Code</td>";
		echo "<td>Product Quantity</td>";
		echo "<td>Product Cost</td>";
		print "</tr>";
		

		while($row = mysql_fetch_array($result))
		{
			print "<tr>";
			print "<td>"; 
			echo $row['Member_Id'];
			echo "</td> <td>";
			echo "<img src= '{$row['ImageSmall']}'>"; 
			echo "</td> <td>";
			echo $row['ProductName'];
			echo "</td> <td>";
			echo $row['Product_Code'];
			echo "</td> <td>";
			echo $row['Product_Quantity'];
			echo "</td><td>";
			echo $row['Product_Cost'];
			echo "</td>";
			print "</tr>";
		}
			
			
		
		print "</table>";
		print "<br>";
		print "The total cost of all item/s is \$".$_SESSION['tcost']."";


?>



<?php


echo"<h2>Checkout</h2>
	
		<form name='checkout' method='post' action = 'checkout.php'>
		
		<fieldset>
		<legend>Checkout</legend>
		
		Credit Card #: <input type='text' size='16' maxlength='16' name='creditcard'> <br>
		<br>
		
		Password: <input type='password' size='20' maxlength='30' name='password'> <br>
		<br>
		
		Address 1:
		<textarea rows='4' name='address' cols='50'>Enter your address here</textarea>
		<br>

		
		
		</fieldset>
		<fieldset>
			
			<input type='submit' value='Checkout' name='checkout'>
			<input type='reset' value='Start over'>
		</fieldset>
		</form>";
		

echo "<fieldset>";
echo $_SESSION['id'];
$id = $_SESSION['id'];
echo "<br>";

if(@$_POST['checkout'])
{
	@$credit =  ($_POST['creditcard']);
	@$password =  ($_POST['password']);
	@$address =  ($_POST['address']);
	
	
	if(isset($_POST['checkout']))
	{
		if(!@$credit | !@$password |!@$address)
		{
			die("Fields left blank. Please enter the informaton. <br/><br/>");
			
		}
		
	}
		
	if(!preg_match ("/^[0-9]{16}+$/", $credit))
	{
		die("Does not match credit card criteria <b>SIXTEEN DIGITS ONLY</b>");
	}

	$con = mysql_connect("localhost","root","") or die ("Could not connect to DB!");
	mysql_select_db ("web project",$con) or die ("could not select DB!");
	
	$sql = "SELECT * FROM credit_info WHERE  Member_Id = '$id'";
	
	$result = mysql_query($sql);
	
	$num_rows = mysql_num_rows($result);
	
	if ($num_rows > 0)
	{
		while($row = mysql_fetch_array($result))
		{
			$credittest = $row['creditcard'];
			$passtest = $row['password'];
			$addresstest = $row['address'];
		}
	}
	
	if (($password == @$passtest) && ($credit == @$credittest) && ($address == @$addresstest))
	{
		print "Billing VERIFIED. <br/>Thank you for shopping at E-Mart";
		
		
		
		$sqlch = "SELECT Product_Code FROM cart";
	
		$resultch = mysql_query($sqlch);
		
		$num_row = mysql_num_rows($resultch);
		
		if ($num_row > 0)
		{
			 
			while($rows = mysql_fetch_array($resultch))
			{
				
				switch ($rows['Product_Code'])
				{
				case "CDDF321":
				
				
				$sqldf = "SELECT Product_Code, SUM( Product_Quantity ) AS DFTOTAL FROM cart
																				HAVING (Product_Code) = 'CDDF321'";
		
				$resultdf = mysql_query($sqldf);
				
				while ($row = mysql_fetch_array($resultdf))
				{
					@$totaldf = $row['DFTOTAL'];	
				}
				
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storedf = @$_SESSION['pquantitydf'] - @$totaldf;
				
				//echo $store;
				
				$usqldf = "UPDATE products SET ProductQuantity = '$storedf' WHERE ProductCode = 'CDDF321'";
				$delsqldf = "DELETE FROM cart WHERE Product_Code = 'CDDF321'";
				
				mysql_query($usqldf);
				mysql_query($delsqldf);
				
				break;
	  
	
				case "BTS1234":
				
				
				$sqlbs = "SELECT Product_Code, SUM( Product_Quantity ) AS BSTOTAL FROM cart
																				HAVING (Product_Code) = 'BTS1234'";
		
				$resultbs = mysql_query($sqlbs);
				
				while ($row = mysql_fetch_array($resultbs))
				{
					@$totalbs = $row['BSTOTAL'];	
				}
				
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storebs = @$_SESSION['pquantitybs'] - @$totalbs;
				
				//echo $store;
				
				$usqlbs = "UPDATE products SET ProductQuantity = '$storebs' WHERE ProductCode = 'BTS1234'";
				$delsqlbs = "DELETE FROM cart WHERE Product_Code = 'BTS1234'";
				
				mysql_query($usqlbs);
				mysql_query($delsqlbs);
				break;
				
				case "CTO8205":
				
				
				$sqloven = "SELECT Product_Code, SUM( Product_Quantity ) AS ovenTOTAL FROM cart
																				HAVING (Product_Code) = 'CTO8205'";
		
				$resultoven = mysql_query($sqloven);
				
				while ($row = mysql_fetch_array($resultoven))
				{
					@$totaloven = $row['ovenTOTAL'];	
				}
				
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storeoven = @$_SESSION['pquantityoven'] - @$totaloven;
				
				//echo $store;
				
				$usqloven = "UPDATE products SET ProductQuantity = '$storeoven' WHERE ProductCode = 'CTO8205'";
				$delsqloven = "DELETE FROM cart WHERE Product_Code = 'CTO8205'";
				
				mysql_query($usqloven);
				mysql_query($delsqloven);
				
				break;
				
				case "BDFP759":
				
				
				$sqlprocessor = "SELECT Product_Code, SUM( Product_Quantity ) AS PTOTAL FROM cart
																				HAVING (Product_Code) = 'BDFP759'";
		
				$resultprocessor = mysql_query($sqlprocessor);
				
				while ($row = mysql_fetch_array($resultprocessor))
				{
					@$totalprocessor = $row['PTOTAL'];	
				}
				
		
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storeprocessor = @$_SESSION['pquantityprocessor'] - @$totalprocessor;
				
				
				$usqlprocessor = "UPDATE products SET ProductQuantity = '$storeprocessor' WHERE ProductCode = BDFP759";
				$delsqlprocessor = "DELETE FROM cart WHERE Product_Code = 'BDFP759'";
				
				mysql_query($usqlprocessor);
				mysql_query($delsqlprocessor);
				
				break;
				
				case "GFG9876":
				
				
				$sqlgr = "SELECT Product_Code, SUM( Product_Quantity ) AS grTOTAL FROM cart
																				HAVING (Product_Code) = 'GFG9876'";
		
				$resultgr = mysql_query($sqlgr);
				
				while ($row = mysql_fetch_array($resultgr))
				{
					@$totalgr = $row['grTOTAL'];	
				}
				
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storegr = @$_SESSION['pquantitygr'] - @$totalgr;
				
				//echo $store;
				
				$usqlgr = "UPDATE products SET ProductQuantity = '$storegr' WHERE ProductCode = 'GFG9876'";
				$delsqlgr = "DELETE FROM cart WHERE Product_Code = 'GFG9876'";
				
				mysql_query($usqlgr);
				mysql_query($delsqlgr);
				
				break;
				
				case "Asus-F20X":
				
				
				$sqlasus = "SELECT Product_Code, SUM( Product_Quantity ) AS asusTOTAL FROM cart
																				HAVING (Product_Code) = 'Asus-F20X'";
		
				$resultasus = mysql_query($sqlasus);
				
				while ($row = mysql_fetch_array($resultasus))
				{
					@$totalasus = $row['asusTOTAL'];	
				}
				
				//echo $totalasus;
				//echo $_SESSION['pquantityasus'];
				
				@$storeasus = @$_SESSION['pquantityasus'] - @$totalasus;
				
				//echo $storeasus;
				
				$usqlasus = "UPDATE products SET ProductQuantity = '$storeasus' WHERE ProductCode = 'Asus-F20X'";
				$delsqlasus = "DELETE FROM cart WHERE Product_Code = 'Asus-F20X'";
				
				mysql_query($usqlasus);
				mysql_query($delsqlasus);
				
				break;
				
				case "AW-J45Z":
				
				
				$sqlali = "SELECT Product_Code, SUM( Product_Quantity ) AS aliTOTAL FROM cart
																				HAVING (Product_Code) = 'AW-J45Z'";
		
				$resultali = mysql_query($sqlali);
				
				while ($row = mysql_fetch_array($resultali))
				{
					@$totalali = $row['aliTOTAL'];	
				}
				
				//echo $totalali; //
				//echo $_SESSION['pquantityali']; //
				
				@$storeali = @$_SESSION['pquantityali'] - @$totalali;
				
				//echo $storeali; //
				
				$usqlali = "UPDATE products SET ProductQuantity = '$storeali' WHERE ProductCode = 'AW-J45Z'";
				$delsqlali = "DELETE FROM cart WHERE Product_Code = 'AW-J45Z'";
				
				mysql_query($usqlali);
				mysql_query($delsqlali);
				
				break;
				
				case "LN-GT48":
				
				
				$sqllen = "SELECT Product_Code, SUM( Product_Quantity ) AS lenTOTAL FROM cart
																				HAVING (Product_Code) = 'LN-GT48'";
		
				$resultlen = mysql_query($sqllen);
				
				while ($row = mysql_fetch_array($resultlen))
				{
					@$totallen = $row['lenTOTAL'];	
				}
				
				//echo $totallen;//
				//echo $_SESSION['pquantitylen'];//
				
				@$storelen = @$_SESSION['pquantitylen'] - @$totallen;
				
				//echo $storelen;//
				
				$usqllen = "UPDATE products SET ProductQuantity = '$storelen' WHERE ProductCode = 'LN-GT48'";
				$delsqllen = "DELETE FROM cart WHERE Product_Code = 'LN-GT48'";
				
				mysql_query($usqllen);
				mysql_query($delsqllen);
				
				break;
				
				case "Acer-B41X":
				
				
				$sqlacer = "SELECT Product_Code, SUM( Product_Quantity ) AS acerTOTAL FROM cart
																				HAVING (Product_Code) = 'Acer-B41X'";
		
				$resultacer = mysql_query($sqlacer);
				
				while ($row = mysql_fetch_array($resultacer))
				{
					@$totalacer = $row['acerTOTAL'];	
				}
				
				//echo $totalacer; //
				//echo $_SESSION['pquantityacer']; //
				
				@$storeacer = @$_SESSION['pquantityacer'] - @$totalacer;
				
				//echo $storeacer; //
				
				$usqlacer = "UPDATE products SET ProductQuantity = '$storeacer' WHERE ProductCode = 'Acer-B41X'";
				$delsqlacer = "DELETE FROM cart WHERE Product_Code = 'Acer-B41X'";
				
				mysql_query($usqlacer);
				mysql_query($delsqlacer);
						
				break;
				
				case "Mac-K94G":
				
				
				$sqlmac = "SELECT Product_Code, SUM( Product_Quantity ) AS macTOTAL FROM cart
																				HAVING (Product_Code) = 'Mac-K94G'";
		
				$resultmac = mysql_query($sqlmac);
				
				while ($row = mysql_fetch_array($resultmac))
				{
					@$totalmac = $row['macTOTAL'];	
				}
				
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storemac = @$_SESSION['pquantitymac'] - @$totalmac;
				
				//echo $store;
				
				$usqlmac = "UPDATE products SET ProductQuantity = '$storemac' WHERE ProductCode = 'Mac-K94G'";
				$delsqlmac = "DELETE FROM cart WHERE Product_Code = 'Mac-K94G'";
				
				mysql_query($usqlmac);
				mysql_query($delsqlmac);
				
				break;
				
				case "Zhd-346u":
				
				$sqlzun = "SELECT Product_Code, SUM( Product_Quantity ) AS zunTOTAL FROM cart
																				HAVING (Product_Code) = 'Zhd-346u'";
		
				$resultzun = mysql_query($sqlzun);
				
				while ($row = mysql_fetch_array($resultzun))
				{
					@$totalzun = $row['zunTOTAL'];	
				}
				
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storezun = @$_SESSION['pquantityzun'] - @$totalzun;
				
				//echo $store;
				
				$usqlzun = "UPDATE products SET ProductQuantity = '$storezun' WHERE ProductCode = 'Zhd-346u'";
				$delsqlzun = "DELETE FROM cart WHERE Product_Code = 'Zhd-346u'";
				
				mysql_query($usqlzun);
				mysql_query($delsqlzun);
				
				break;
				
				case "Clz-82gb":
				
				$sqlzen = "SELECT Product_Code, SUM( Product_Quantity ) AS zenTOTAL FROM cart
																				HAVING (Product_Code) = 'Clz-82gb'";
		
				$resultzen = mysql_query($sqlzen);
				
				while ($row = mysql_fetch_array($resultzen))
				{
					@$totalzen = $row['zenTOTAL'];	
				}
				
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storezen = @$_SESSION['pquantityzen'] - @$totalzen;
				
				//echo $store;
				
				$usqlzen = "UPDATE products SET ProductQuantity = '$storezen' WHERE ProductCode = 'Clz-82gb'";
				$delsqlzen = "DELETE FROM cart WHERE Product_Code = 'Clz-82gb'";
				
				mysql_query($usqlzen);
				mysql_query($delsqlzen);
				break;
				
				case "nr-43s54":
				
				$sqlsony = "SELECT Product_Code, SUM( Product_Quantity ) AS sonyTOTAL FROM cart
																				HAVING (Product_Code) = 'nr-43s54'";
		
				$resultsony = mysql_query($sqlsony);
				
				while ($row = mysql_fetch_array($resultsony))
				{
					@$totalsony = $row['sonyTOTAL'];	
				}
				
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storesony = @$_SESSION['pquantitysony'] - @$totalsony;
				
				//echo $store;
				
				$usqlsony = "UPDATE products SET ProductQuantity = '$storesony' WHERE ProductCode = 'nr-43s54'";
				$delsqlsony = "DELETE FROM cart WHERE Product_Code = 'nr-43s54'";
				
				mysql_query($usqlsony);
				mysql_query($delsqlsony);
				break;
				
				case "ph-gg11a":
				
				$sqlphil = "SELECT Product_Code, SUM( Product_Quantity ) AS philTOTAL FROM cart
																				HAVING (Product_Code) = 'ph-gg11a'";
		
				$resultphil = mysql_query($sqlphil);
				
				while ($row = mysql_fetch_array($resultphil))
				{
					@$totalphil = $row['philTOTAL'];	
				}
				
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storephil = @$_SESSION['pquantityphil'] - @$totalphil;
				
				//echo $store;
				
				$usqlphil = "UPDATE products SET ProductQuantity = '$storephil' WHERE ProductCode = 'ph-gg11a'";
				$delsqlphil = "DELETE FROM cart WHERE Product_Code = 'ph-gg11a'";
				
				mysql_query($usqlphil);
				mysql_query($delsqlphil);
				break;
				
				case "Pod-a132b":
				
				$sqlapp = "SELECT Product_Code, SUM( Product_Quantity ) AS appTOTAL FROM cart
																				HAVING (Product_Code) = 'Pod-a132b'";
		
				$resultapp = mysql_query($sqlapp);
				
				while ($row = mysql_fetch_array($resultapp))
				{
					@$totalapp = $row['appTOTAL'];	
				}
				
				//echo $totalblacberry;
				//echo $_SESSION['pquantityblacberry'];
				
				@$storeapp = @$_SESSION['pquantityapp'] - @$totalapp;
				
				//echo $store;
				
				$usqlapp = "UPDATE products SET ProductQuantity = '$storeapp' WHERE ProductCode = 'Pod-a132b'";
				$delsqlapp = "DELETE FROM cart WHERE Product_Code = 'Pod-a132b'";
				
				mysql_query($usqlapp);
				mysql_query($delsqlapp);
				break;
	 
				default:
				}
			}
		}
		/*$sqlblacberry = "SELECT Product_Code, SUM( Product_Quantity ) AS QTOTAL FROM cart
																				HAVING (Product_Code) =121";
		
		$uresult = mysql_query($sqlblacberry);
		
		while ($row = mysql_fetch_array($uresult))
		{
			$totalblacberry = $row['QTOTAL'];	
		}
		
		//echo $totalblacberry;
		//echo $_SESSION['pquantityblacberry'];
		
		$store = $_SESSION['pquantityblacberry'] - $totalblacberry;
		
		//echo $store;
		
		$usqlblacberry = "UPDATE products SET ProductQuantity = '$store' WHERE ProductCode = '121'";
		$delsqlblacberry = "DELETE FROM cart WHERE Product_Code = '121'";
		
		mysql_query($usqlblacberry);
		mysql_query($delsqlblacberry);*/
		
		//Appliance products update
		
		
		/*$sqldf = "SELECT Product_Code, SUM( Product_Quantity ) AS DFTOTAL FROM cart
																				HAVING (Product_Code) = 'CDDF321'";
		
		$resultdf = mysql_query($sqldf);
		
		while ($row = mysql_fetch_array($resultdf))
		{
			@$totaldf = $row['DFTOTAL'];	
		}
		
		//echo $totalblacberry;
		//echo $_SESSION['pquantityblacberry'];
		
		@$storedf = @$_SESSION['pquantitydf'] - @$totaldf;
		
		//echo $store;
		
		$usqldf = "UPDATE products SET ProductQuantity = '$storedf' WHERE ProductCode = 'CDDF321'";
		$delsqldf = "DELETE FROM cart WHERE Product_Code = 'CDDF321'";
		
		mysql_query($usqldf);
		mysql_query($delsqldf);
		
		
		
		$sqlbs = "SELECT Product_Code, SUM( Product_Quantity ) AS BSTOTAL FROM cart
																				HAVING (Product_Code) = 'BTS1234'";
		
		$resultbs = mysql_query($sqlbs);
		
		while ($row = mysql_fetch_array($resultbs))
		{
			@$totalbs = $row['BSTOTAL'];	
		}
		
		//echo $totalblacberry;
		//echo $_SESSION['pquantityblacberry'];
		
		@$storebs = @$_SESSION['pquantitybs'] - @$totalbs;
		
		//echo $store;
		
		$usqlbs = "UPDATE products SET ProductQuantity = '$storebs' WHERE ProductCode = 'BTS1234'";
		$delsqlbs = "DELETE FROM cart WHERE Product_Code = 'BTS1234'";
		
		mysql_query($usqlbs);
		mysql_query($delsqlbs);
		
		
		$sqloven = "SELECT Product_Code, SUM( Product_Quantity ) AS ovenTOTAL FROM cart
																				HAVING (Product_Code) = 'CTO8205'";
		
		$resultoven = mysql_query($sqloven);
		
		while ($row = mysql_fetch_array($resultoven))
		{
			@$totaloven = $row['ovenTOTAL'];	
		}
		
		//echo $totalblacberry;
		//echo $_SESSION['pquantityblacberry'];
		
		@$storeoven = @$_SESSION['pquantityoven'] - @$totaloven;
		
		//echo $store;
		
		$usqloven = "UPDATE products SET ProductQuantity = '$storeoven' WHERE ProductCode = 'CTO8205'";
		$delsqloven = "DELETE FROM cart WHERE Product_Code = 'CTO8205'";
		
		mysql_query($usqloven);
		mysql_query($delsqloven);
		
		
		
		$sqlprocessor = "SELECT Product_Code, SUM( Product_Quantity ) AS PTOTAL FROM cart
																				HAVING (Product_Code) = 'BDFP759'";
		
		$resultprocessor = mysql_query($sqlprocessor);
		
		while ($row = mysql_fetch_array($resultprocessor))
		{
			@$totalprocessor = $row['PTOTAL'];	
		}
		

		//echo $totalblacberry;
		//echo $_SESSION['pquantityblacberry'];
		
		@$storeprocessor = @$_SESSION['pquantityprocessor'] - @$totalprocessor;
		
		
		$usqlprocessor = "UPDATE products SET ProductQuantity = '$storeprocessor' WHERE ProductCode = BDFP759";
		$delsqlprocessor = "DELETE FROM cart WHERE Product_Code = 'BDFP759'";
		
		mysql_query($usqlprocessor);
		mysql_query($delsqlprocessor);
	
		
		
		
		$sqlgr = "SELECT Product_Code, SUM( Product_Quantity ) AS grTOTAL FROM cart
																				HAVING (Product_Code) = 'GFG9876'";
		
		$resultgr = mysql_query($sqlgr);
		
		while ($row = mysql_fetch_array($resultgr))
		{
			@$totalgr = $row['grTOTAL'];	
		}
		
		//echo $totalblacberry;
		//echo $_SESSION['pquantityblacberry'];
		
		@$storegr = @$_SESSION['pquantitygr'] - @$totalgr;
		
		//echo $store;
		
		$usqlgr = "UPDATE products SET ProductQuantity = '$storegr' WHERE ProductCode = 'GFG9876'";
		$delsqlgr = "DELETE FROM cart WHERE Product_Code = 'GFG9876'";
		
		mysql_query($usqlgr);
		mysql_query($delsqlgr);
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		
		//Computer update
		$sqlasus = "SELECT Product_Code, SUM( Product_Quantity ) AS asusTOTAL FROM cart
																				HAVING (Product_Code) = 'Asus-F20X'";
		
		$resultasus = mysql_query($sqlasus);
		
		while ($row = mysql_fetch_array($resultasus))
		{
			@$totalasus = $row['asusTOTAL'];	
		}
		
		//echo $totalasus;
		//echo $_SESSION['pquantityasus'];
		
		@$storeasus = @$_SESSION['pquantityasus'] - @$totalasus;
		
		//echo $storeasus;
		
		$usqlasus = "UPDATE products SET ProductQuantity = '$storeasus' WHERE ProductCode = 'Asus-F20X'";
		$delsqlasus = "DELETE FROM cart WHERE Product_Code = 'Asus-F20X'";
		
		mysql_query($usqlasus);
		mysql_query($delsqlasus);
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		$sqlali = "SELECT Product_Code, SUM( Product_Quantity ) AS aliTOTAL FROM cart
																				HAVING (Product_Code) = 'AW-J45Z'";
		
		$resultali = mysql_query($sqlali);
		
		while ($row = mysql_fetch_array($resultali))
		{
			@$totalali = $row['aliTOTAL'];	
		}
		
		//echo $totalali; //
		//echo $_SESSION['pquantityali']; //
		
		@$storeali = @$_SESSION['pquantityali'] - @$totalali;
		
		//echo $storeali; //
		
		$usqlali = "UPDATE products SET ProductQuantity = '$storeali' WHERE ProductCode = 'AW-J45Z'";
		$delsqlali = "DELETE FROM cart WHERE Product_Code = 'AW-J45Z'";
		
		mysql_query($usqlali);
		mysql_query($delsqlali);
		
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
		
		$sqllen = "SELECT Product_Code, SUM( Product_Quantity ) AS lenTOTAL FROM cart
																				HAVING (Product_Code) = 'LN-GT48'";
		
		$resultlen = mysql_query($sqllen);
		
		while ($row = mysql_fetch_array($resultlen))
		{
			@$totallen = $row['lenTOTAL'];	
		}
		
		//echo $totallen;//
		//echo $_SESSION['pquantitylen'];//
		
		@$storelen = @$_SESSION['pquantitylen'] - @$totallen;
		
		//echo $storelen;//
		
		$usqllen = "UPDATE products SET ProductQuantity = '$storelen' WHERE ProductCode = 'LN-GT48'";
		$delsqllen = "DELETE FROM cart WHERE Product_Code = 'LN-GT48'";
		
		mysql_query($usqllen);
		mysql_query($delsqllen);
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		$sqlacer = "SELECT Product_Code, SUM( Product_Quantity ) AS acerTOTAL FROM cart
																				HAVING (Product_Code) = 'Acer-B41X'";
		
		$resultacer = mysql_query($sqlacer);
		
		while ($row = mysql_fetch_array($resultacer))
		{
			@$totalacer = $row['acerTOTAL'];	
		}
		
		//echo $totalacer; //
		//echo $_SESSION['pquantityacer']; //
		
		@$storeacer = @$_SESSION['pquantityacer'] - @$totalacer;
		
		//echo $storeacer; //
		
		$usqlacer = "UPDATE products SET ProductQuantity = '$storeacer' WHERE ProductCode = 'Acer-B41X'";
		$delsqlacer = "DELETE FROM cart WHERE Product_Code = 'Acer-B41X'";
		
		mysql_query($usqlacer);
		mysql_query($delsqlacer);
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		$sqlmac = "SELECT Product_Code, SUM( Product_Quantity ) AS macTOTAL FROM cart
																				HAVING (Product_Code) = 'Mac-K94G'";
		
		$resultmac = mysql_query($sqlmac);
		
		while ($row = mysql_fetch_array($resultmac))
		{
			@$totalmac = $row['macTOTAL'];	
		}
		
		//echo $totalblacberry;
		//echo $_SESSION['pquantityblacberry'];
		
		@$storemac = @$_SESSION['pquantitymac'] - @$totalmac;
		
		//echo $store;
		
		$usqlmac = "UPDATE products SET ProductQuantity = '$storemac' WHERE ProductCode = 'Mac-K94G'";
		$delsqlmac = "DELETE FROM cart WHERE Product_Code = 'Mac-K94G'";
		
		mysql_query($usqlmac);
		mysql_query($delsqlmac);*/
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		mysql_close($con);
	}
	
	else 
	{
		print"Please check your credit card number, password or address";
		echo "<br/>";
	
		
		}
	echo "</fieldset>"; 
}

?>
</div>
<div id="apDiv22" style="background-image:url(../../Resources/Footer%20Image.png); background-repeat:no-repeat">


</div>
</body>
</html> 